<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/2
 * Time: 20:29
 */

namespace app\index\controller;

use app\common\controller\IndexBase;
use think\Db;
use think\Cache;

class Rank extends IndexBase{
    /**
     * 统计排名榜
     */
    public function scoreRank(){
        header("Content-type:text/html;charset=utf-8");
        $sql  = "select a.username,sum(c.score) as points from sjb_user a left join sjb_record b on a.usercode=b.usercode left join sjb_teamvs c on b.competitionId = c.id where b.team=c.competition_res group by a.usercode order by sum(c.score) desc";
        $data = Db::query($sql);
        if(!$data){
            exit("<script>alert('my god');window.history.go(-1);</script>");
        }
        return $this->fetch('index/rank', array('data' => $data));
    }
}

